package com.sinoglobal.ningxia.adapter;

import java.util.List;

import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import com.sinoglobal.ningxia.R;

/**
 * 
 * @author zbl
 * @createdate 2014-6-24 上午10:42:32
 * @Description: TODO(用一句话描述该类做什么)精品商城中首页Viewpager的adapter
 */
public class ShoppingPagerAdapter extends PagerAdapter {

	private List<View> list;

	public ShoppingPagerAdapter(List<View> list) {
		super();
		this.list = list;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public boolean isViewFromObject(View arg0, Object arg1) {
		return arg0 == arg1;
	}

	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
		super.destroyItem(container, position, object);
		((ViewPager) container).removeView(list.get(position));
	}

	@Override
	public Object instantiateItem(ViewGroup container, int position) {
		((ViewPager) container).addView(list.get(position));

		return list.get(position);
	}

}
